package webbrow.member.model;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MemberServiceImpl implements MemberService {
	private MemberDao memberDao;
	public MemberServiceImpl(MemberDao memberDao){
		this.memberDao = memberDao;
	}

	@Override
	public int isExistId(String id) throws SQLException{
		return memberDao.selectCountById(id);
	}
	@Override
	public int isExistEmail(MemberVO mvo) throws SQLException {
		// TODO Auto-generated method stub
		return memberDao.selectCountByEmail(mvo);
	}
	@Override
	public void registerMember(MemberVO mvo) throws SQLException {
		memberDao.insertMember(mvo);
		
	}
	@Override
	public MemberVO loginMember(MemberVO mvo) throws SQLException {
		
		return memberDao.selectMemberByLogin(mvo);
	}
	@Override
	public void updateMember(MemberVO mvo) throws SQLException{
		memberDao.updateMember(mvo);
	}
	
	@Override
	public MemberVO showMyInfo(String id) throws SQLException{
		// TODO Auto-generated method stub
		return memberDao.selectMyInfo(id);
	}
	@Override
	public MemberVO showMemberInfo(MemberVO vo) {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public int secessionMember(String id) throws SQLException {
		// TODO Auto-generated method stub
		return memberDao.updateDropout(id);
	}
	/**
	 * 관리자 페이지 - 전체 회원 리스트 보기
	 */
	@Override
	public List<MemberVO> showMemberList() throws SQLException {
		return memberDao.selectMemberAll();
	}
     // 이메일 중복체크 : 회원가입
	@Override
	public int isExistEmailReg(String email) throws SQLException {
		// TODO Auto-generated method stub
		return memberDao.selectCountByEmailReg(email);
	}

	@Override
	public String checkPassword(String id,String email) throws SQLException {
		// TODO Auto-generated method stub
		HashMap map=new HashMap();
		map.put("id", id);
		map.put("email", email);
		return memberDao.selectPasswordByUserInfo(map);
	}

	@Override
	public int confirmDropout(String id) throws SQLException {
		return memberDao.selectDropout(id);
	}



}
